package xin.mashibo.pattern.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * 数值生成抽象类
 *
 * @author MaShibo
 * 日期 :  2019/1/28
 */
public abstract class NumberGenerator {

    private List<Observer> observers = new ArrayList<>();

    public void addObserver(Observer observer) {
        observers.add(observer);
    }

    public void deleteObserver(Observer observer) {
        observers.remove(observer);
    }

    public void notifyObservers() {
        for (Observer observer : observers) {
            observer.update(this);
        }
    }

    public abstract int getNumber();

    public abstract void execute();

}
